package com.co.persistence;

import java.io.File;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils {

	// private static HibernateUtils instance;
	//
	// public static HibernateUtils getInstance(){
	// if (instance == null)
	// instance = new HibernateUtils();
	// return instance;
	// }
	private static final String HIBERNATE_CONF_PATH = "D:\\workspace\\Sistemas Odontologicos\\src\\src\\hibernate.cfg.xml";

	private static final SessionFactory sessionFactory;
	static {
		try {
			// D:\workspace\Sistemas Odontologicos\src\src\hibernate.cfg.xml
			File file = new File(HIBERNATE_CONF_PATH);
			sessionFactory = new Configuration().configure(file)
					.buildSessionFactory();
		} catch (Throwable ex) {
			System.err.println("Initial SessionFactory creation failed." + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}